package jannex.query;

import jannex.JannexException;

import java.util.Map;

// TODO 2014-08-11 replace this with
public class Binding<E> {

    private final PlannedStatement<E> statement;

    public Binding(PlannedStatement<E> statement) {
        this.statement = statement;
    }

    @SuppressWarnings({"raw", "unchecked"})
    public <E> void register(Clause<E> clause) {
        ((Map) statement.clauseMap).put(clause.getClass(), clause);
    }

    public PlannedStatement getStatement() {
        return statement;
    }

    public static final Binding<?> NULL = new Binding<Object>(null) {
        @Override
        public <E> void register(Clause<E> clause) {
            // TODO what?
            throw new JannexException("Say what?");
        }

        @Override
        public PlannedStatement getStatement() {
            throw new JannexException("Cannot get resultSet from unbound clause");
        }
    };


}
